home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14707 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: linus.mitre.org!spectre!eachus
  2. From: eachus@spectre.mitre.org (Robert I. Eachus)
  3. Newsgroups: comp.lang.ada,comp.lang.c++
  4. Subject: Re: Iterators (was Re: some questions re. Ada/GNAT from a C++/GCC user)
  5. Date: 01 Apr 1996 20:38:13 GMT
  6. Organization: The Mitre Corp., Bedford, MA.
  7. Message-ID: <EACHUS.96Apr1153813@spectre.mitre.org>
  8. References: <wnewmanDoxrCp.DKv@netcom.com> <Dp1oAw.7Cz@world.std.com>
  9.     <EACHUS.96Mar29191146@spectre.mitre.org> <4jlmn5$h1k@Nntp1.mcs.net>
  10. NNTP-Posting-Host: spectre.mitre.org
  11. In-reply-to: mikey@mcs.com's message of 31 Mar 1996 10:27:49 GMT
  12.  
  13.  
  14.     In article <EACHUS.96Mar29191146@spectre.mitre.org>, I said:
  15.  
  16.    > The choice was between Ada and a shell script...I chose Ada.
  17.  
  18.   In article <4jlmn5$h1k@Nntp1.mcs.net> mikey@mcs.com (Mike Young) writes:
  19.  
  20.    > I don't know about that, Robert. The equivalent shell script would be...
  21.  
  22.     No, that would NOT be the equivalent shell script.  Yes, that is
  23. similar to the approach I would have taken with a shell script, but
  24. the main difference is that the shell script would invoke a program
  25. once for each file, while the Ada approach allowed me to invoke a
  26. subprogram WITHIN a program once for each file name.
  27.  
  28.     Now the actual tasks the tools were doing were such that having a
  29. single program run 1000 times with state passed through (other) files
  30. would have resulted in O(N squared) preformance as the state files to
  31. be read in each time got larger and larger.  Another path I considered
  32. was to use a script to catenate all files together--in a pipe, not a
  33. file--then write a separate program to take the pipe as input.  In
  34. that case I lose the advantages of having the file name as "out of
  35. band" information.  I'd have to prepend a structured comment to each
  36. file before piping it, and on the other end, look for the structured
  37. comments and process them.
  38.  
  39.     Also, I could have used a DBMS, but that would have required
  40. different DDL and SQL for each of several tools, where with the all
  41. Ada approach much of the code could be shared.
  42.  
  43.     So after doing a quick analysis, writing a file iterator--which
  44. took about two hours to write and debug--was by far the best solution.
  45. I posted the code because others may find it useful as well, even in
  46. cases where the "simple" shell script would work.
  47. --
  48.  
  49.                     Robert I. Eachus
  50.  
  51. with Standard_Disclaimer;
  52. use  Standard_Disclaimer;
  53. function Message (Text: in Clever_Ideas) return Better_Ideas is...
  54.